package com.neusoft.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.neusoft.domain.PageResult;
import com.neusoft.domain.Shop;
import com.neusoft.mapper.ShopMapper;
import com.neusoft.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShopServiceImpl implements ShopService {
    @Autowired
    private ShopMapper shopMapper;
    @Override
    public PageResult<Shop> pageSelectShop(Integer pageNum, Integer pageSize, String shop_name, String shop_address) {
        PageHelper.startPage(pageNum,pageSize);
        List<Shop> shops = shopMapper.pageSelectShop(shop_name, shop_address);
        PageInfo pageInfo = new PageInfo(shops);
        return new PageResult<Shop>(pageInfo.getTotal(),pageInfo.getList());
    }

    @Override
    public void recommendShop(Integer shopId, Integer recommend) {
        recommend++;
        shopMapper.recommendShop(shopId, recommend);
    }
}
